#!../sl

:- import "%%/lib/os.sl" #

apacheHome "/opt/apache" #

killPidFromFile .pidFile :-
	not (file.exists .pidFile) ! #
killPidFromFile .pidFile :-
	stream.readFile .stream .pidFile,
	stream.line .stream .pid,
	stream.close .stream,
	process.kill .pid #

:-	home.dir .home,
	concat .home "/ssp" .sspHome
	,
	-- Re-generates sl source from ssp
	execute (.sspHome "/sspc.sl")
	,
	-- Restarts database tier
	concat .sspHome "/.processid" .pidFile,
	killPidFromFile .pidFile,
	execute ("nohup " .sspHome "/database.sl > /dev/null & echo $! > " .pidFile)
	,
	-- Restarts apache
	apacheHome .apacheHome,
	execute (.apacheHome "/bin/apachectl restart")
	,
	-- Back to command line
	quit #
